package com.crm.miaohe.controller.deposit;

import javax.validation.Valid;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.crm.miaohe.controller.PageResponse;
import com.crm.miaohe.controller.depoist.request.DepositDetailParams;
import com.crm.miaohe.controller.depoist.request.DepositDetailQueryParams;
import com.crm.miaohe.model.TblDepositDetails;
import com.crm.miaohe.service.DepositDetailService;

@RestController
@RequestMapping("/api/erp/deposit")
public class DepositController {

    private final DepositDetailService sepositDetailService;

    public DepositController(DepositDetailService sepositDetailService) {
        this.sepositDetailService = sepositDetailService;
    }

    @PostMapping("/register")
    public ResponseEntity<Void> registerCustomer(@RequestBody @Valid DepositDetailParams params) {
    	sepositDetailService.addDepositDetail(params);
        return ResponseEntity.ok().build();
    }

    @GetMapping("/list")
    public ResponseEntity<PageResponse<TblDepositDetails>> overview(@Valid DepositDetailQueryParams params) {
        return ResponseEntity.ok(sepositDetailService.getDepositDetails(params));
    }
}
